package Demo;

public class Demo02 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread( () -> {
            while (!Thread.interrupted()) {
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    System.out.println("线程中断");
                    break;
                }
            }
        });
        t.start();
        Thread.sleep(6000);
        System.out.println("hello main");
        t.interrupt();
    }
}
